#include<stdio.h>

void main()
{
    int N,new_el,key,i,pos;
    printf("Enter the no. of element :");
    scanf("%d",&N);
    int array[N];
    for(i=0;i<N;i++)
    {
        printf("Enter the element : ");
        scanf("%d",&array[i]);
    }
    while(1)
    { int choice;

        printf("1. Append");
        printf("2. Insert");
        printf("3. Remove");
        printf("4. pop");
        printf("5. display");
        printf("6. find");
        printf("Enter your choice : ");        
        scanf("%d",&choice);
        switch(choice)
        {
            case 1:
                   printf("Enter the new element : ");
                   scanf("%d",&new_el);
                   array[N]=new_el;
                   N++;
                   break;
            case 2:
                   printf("Enter the position at which you want to insert : ");
                   scanf("%d",&pos);
                   printf("Enter the new element : ");
                   scanf("%d",&new_el);
                   pos--;
                     for(i = N-1; i>=pos ;i--)
                      array[i+1]=array[i];
                      array[pos]=new_el;
                      N++;
                      break;
            case 3:
                   printf("Enter the value to be search : ");
                   scanf("%d",&key);
                    for(pos=0;pos<N;pos++)
                    {
                      if(array[pos]==key)
                        break;
                    }
                   if(pos==N)
                    {
                    printf("Search key not found");
                    break;
                    }
                     for(i=pos;i<N;i++)
                      array[i]=array[i+1];
                      N--;
                     break;
            case 4:
                   printf("Enter the position to be changed : ");
                   scanf("%d",&pos);
                   printf("Enter the new value for old position : ");
                   scanf("%d",&array[pos-1]);
                   break;
            case 5:
                   for(i=0;i<N;i++)
                    {
                    printf("The element is : ",array[i]);
					}
                   break;
            case 6:
                   printf("Enter the value to be search : ");
                   scanf("%d",&key);
                    for(pos=0;pos<N;pos++)
                     {
                      if(array[pos]==key)
                        break;
                     }
                     if(pos == N)
                     {
                       printf("Search key not found");
                       break;
                     }
                   printf("Search key found at : ",pos+1);
                   break;
            case 7: break;
        }
    }
}
